﻿using System;
using System.Collections.Generic;
using System.Text;

namespace MethodReturnValueContracts
{
    class Program
    {
        static void Main(string[] args)
        {
            PreventingNull.SimpleValue("hello");
            Console.WriteLine("1) PreventingNull.SimpleValue(\"hello\") passed without throwing exception");

            try
            {
                PreventingNull.SimpleValue(null);
            }
            catch (InvalidOperationException)
            {
                Console.WriteLine("2) PreventingNull.SimpleValue(null) threw System.InvalidOperationException");
            }

            PreventingNull.SimpleValueAndCustomException("hello");
            Console.WriteLine("3) PreventingNull.SimpleValueAndCustomException(\"hello\") passed without throwing exception");

            try
            {
                PreventingNull.SimpleValueAndCustomException(null);
            }
            catch (ArgumentNullException)
            {
                Console.WriteLine("4) PreventingNull.SimpleValueAndCustomException(null) threw System.ArgumentNullException");
            }

            PreventingNull.CollectionValue(new string[] { "a", "b", "c" });
            Console.WriteLine("5) PreventingNull.CollectionValue(new string[] { \"a\", \"b\", \"c\" }) passed without throwing exception");

            try
            {
                PreventingNull.CollectionValue(new string[] { "a", null, "c" });
            }
            catch (InvalidOperationException)
            {
                Console.WriteLine("6) PreventingNull.CollectionValue(new string[] { \"a\", null, \"c\" }) threw System.InvalidOperationException");
            }

            PreventingNull.CollectionValueAndCustomException(new string[] { "a", "b", "c" });
            Console.WriteLine("7) PreventingNull.CollectionValueAndCustomException(new string[] { \"a\", \"b\", \"c\" }) passed without throwing exception");

            try
            {
                PreventingNull.CollectionValueAndCustomException(new string[] { "a", null, "c" });
            }
            catch (ArgumentException)
            {
                Console.WriteLine("8) PreventingNull.CollectionValueAndCustomException(new string[] { \"a\", null, \"c\" }) threw System.ArgumentException");
            }

            BoundaryChecking.SimpleCondition(3.3);
            Console.WriteLine("9) BoundaryChecking.SimpleCondition(3.3) passed without throwing exception");

            try
            {
                BoundaryChecking.SimpleCondition(3.4);
            }
            catch (InvalidOperationException)
            {
                Console.WriteLine("10) BoundaryChecking.SimpleCondition(3.4) threw System.InvalidOperationException");
            }

            BoundaryChecking.EqualityCheck(13L);
            Console.WriteLine("11) BoundaryChecking.EqualityCheck(13L) passed without throwing exception");

            try
            {
                BoundaryChecking.EqualityCheck(12L);
            }
            catch (InvalidOperationException)
            {
                Console.WriteLine("12) BoundaryChecking.EqualityCheck(12L) threw System.InvalidOperationException");
            }

            UniversalQuantification.SimpleCondition(new double[] { 5.0, 5.5, 6.6 });
            Console.WriteLine("13) UniversalQuantification.SimpleCondition(new double[] { 5.0, 5.5, 6.6 }) passed without throwing exception");

            try
            {
                UniversalQuantification.SimpleCondition(new double[] { 5.5, 6.6, 6.7 });
            }
            catch (InvalidOperationException)
            {
                Console.WriteLine("14) UniversalQuantification.SimpleCondition(new double[] { 5.5, 6.6, 6.7 }) threw System.InvalidOperationException");
            }

            UniversalQuantification.EqualityCheck(new string[] { "#", "#", "#" });
            Console.WriteLine("15) UniversalQuantification.EqualityCheck(new string[] { \"#\", \"#\", \"#\" }) passed without throwing exception");

            try
            {
                UniversalQuantification.EqualityCheck(new string[] { "#", "hey!", "#" });
            }
            catch (InvalidOperationException)
            {
                Console.WriteLine("16) UniversalQuantification.EqualityCheck(new string[] { \"#\", \"hey!\", \"#\" }) threw System.InvalidOperationException");
            }

            ExistentialQuantification.SimpleCondition(new double[] { 5.0, 5.0, 2.2, 5.0 });
            Console.WriteLine("17) ExtentialQuantification.SimpleCondition(new double[] { 5.0, 5.0, 2.2, 5.0 }) passed without throwing exception");

            try
            {
                ExistentialQuantification.SimpleCondition(new double[] { 5.0, 5.0, 5.0, 5.0 });
            }
            catch (InvalidOperationException)
            {
                Console.WriteLine("18) ExistentialQuantification.SimpleCondition(new double[] { 5.0, 5.0, 5.0, 5.0 } threw System.InvalidOperationException");
            }

            ExistentialQuantification.EqualityCheck(new string[] { "a", "hey!", "c" });
            Console.WriteLine("19) ExistentialQuantification.EqualityCheck(new string[] { \"a\", \"hey!\", \"c\" })");

            try
            {
                ExistentialQuantification.EqualityCheck(new string[] { "a", "b", "c" });
            }
            catch (InvalidOperationException)
            {
                Console.WriteLine("20) ExistentialQuantification.EqualityCheck(new string[] { \"a\", \"b\", \"c\" }) threw System.InvalidOperationException");
            }
        }
    }
}
